<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新用户注册 - ${site.name} - Powered by JEECMS</title>
<script src="${resSys}/jquery.js" type="text/javascript"></script>
<script src="${resSys}/front.js" type="text/javascript"></script>
<script src="${resSys}/xcConfirm/front.js" type="text/javascript"></script>

<link type="text/css" rel="stylesheet" href="/${res}/css/index.css" />
<link type="text/css" rel="stylesheet" href="/${res}/css/xcConfirm/css/xcConfirm.css" />

<!--[if lt IE 9]> 
<script src="/${res}/js/html5shiv.min.js"></script>
<script src="/${res}/js/respond.min.js"></script>
<![endif]-->
<style>
 .disable-btn{
 	background-color:#ccc !important;
 }
</style>
<script type="text/javascript">
	function isPoneAvailable(str) {  
	    var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;  
	    if (!myreg.test(str)) {  
	        return false;  
	    } else {  
	        return true;  
	    }  
	}  
	
	function guestbookCaptcha(){
		$('#guestbookCaptcha').attr("src","${base}/captcha.svl?d="+Math.random());
    }
	
    $(function() {
       $("#jvForm").validate();
       $("#ck-agree").on('click',function(){
    	   if($(this).is(":checked")){
    		   $("#btn_sub").removeAttr("disabled").removeAttr("class");
    	   }else{
    		   $("#btn_sub").attr("disabled","disabled").attr("class","disable-btn");
    		   
    	   }
       });
       /* $("#jvForm").bind("submit",function(){
    	   if($("#ck-agree").is(':checked') == false){
    		   window.wxc.xcConfirm("请选择我已阅读并接受!", window.wxc.xcConfirm.typeEnum.warning);
    		   return false;
           }
       }); */
       $("#guestbookCaptcha").bind("click", function(){
         $(this).attr("src","${base}/captcha.svl?d="+Math.random());
       });
       $("#getMobileCode").bind("click", function(){
    	   var flag =  $("#jvForm").valid();
    	   if(flag){
	           var mobile = $("#mobile").val();
	       		// 判断手机号码
	           if ($.trim($('#mobile').val()).length == 0) { 
	            alert('手机号没有输入\n');
	            $('#mobile').focus();
	           }else if(!isPoneAvailable(mobile)){
	        	   alert("请输入正确的手机号码！");
	           }else if($.trim($('#vCode').val()).length == 0){
	        	   alert("请输入验证码！");
	           }else if($.trim($('#vCode').val()).length != 4){
	        	   alert("请输入正确的验证码！");
	           }else if($.trim($('#username').val()).length == 0){
	        	   alert("请输入用户名！");
	           }else{
	        	   $.ajax({
	        	        type:"POST",
	        	        url:"${base}/sms/send_register_msg.jspx",
	        	         data:{
	        	        	mobilePhone:$("#mobile").val(),
	        	        	smsSendType:1,
	        	        	vCode:$("#vCode").val()
	        	        },
	        	        dataType:"json",     
	        	        success:function(data){
	        	        	if(data.code ==200){
	        	        		alert("发送成功！");
	        	        	}else if(data.code == 356){
	        	            	alert("该手机号已达到每日上限！");        	        		
	        	        	}else if(data.code ==357){
	        	        		alert("该手机号已被绑定！");
	        	        	}else if(data.code ==354){
	        	        		alert("发送短信间隔过短！");
	        	        	}else if(data.code ==353){
	        	        		guestbookCaptcha();
	        	        		alert("验证码错误！");
	        	        	}else if(data.code ==101){
	        	        		guestbookCaptcha();
	        	        		alert("验证码已失效！");
	        	        	}else if(data.message =="sms_error"){
	        	        		alert("短信请求错误，请联系本站管理员！");
	        	        	}else{
	        	        		alert(data.message);
	        	        	}
	        	        },
	        	        error:function(jqXHR){
	        	            
	        	        }
	        	    });
	           } 
    	   } });
      
    });
</script>

</head>

<body style="background-color:#f7f7f7;">
[#include "../include/top.html"/]
[#include "../include/header.html"/] 
<div class="register-box"> 
  <div class="register-nav"><span>注册</span><div class="register-login">已有账号，<a class="tc" href="${base}/login.jspx">马上登录 ></a></div></div> 
  <form id="jvForm" action="${base}/register.jspx" method="post">
  <div class="register-list">
    <ul>
      <li><span>用户名</span><input type="text" id="username"  vld="{required:true,rangelength:[${site.usernameMinLen},20],username:true,remote:'username_unique.jspx',messages:{remote:'用户名已存在'}}" name="username" placeholder="${site.usernameMinLen}~20字符，中文字符/英文字母/数字" class="register-input" /></li>
      [#if validateType == 0]
      <li><span>电子邮箱</span><input type="text" id="email" maxlength="30" vld="{remote:'email_unique.jspx',messages:{remote:'email已被使用！'}}" name="email" placeholder="用于找回密码" class="register-input" /></li>
      [/#if]
      [#if validateType == 2]
      <li><span>电子邮箱</span><input type="text" id="email" maxlength="30" vld="{remote:'email_unique.jspx',messages:{remote:'email已被使用！'}}" name="email" placeholder="用于找回密码" class="register-input" /></li>
      <li><span>手机号码</span><input type="text" id="mobile" maxlength="11" vld="{required:true,remote:'mobilePhone_unique.jspx',messages:{remote:'手机号已被使用！'}}" name="mobile" placeholder="用于找回密码" class="register-input" /></li>      
      [/#if]
      [#if validateType == 1]
      	<li><span>电子邮箱</span><input type="text" id="email" maxlength="30" vld="{required:true,remote:'email_unique.jspx',messages:{remote:'email已被使用！'}}" name="email" placeholder="用于找回密码" class="register-input" /></li>
      [/#if]
      <li><span>设置密码</span><input id="password" type="password" name="loginPassword" vld="{required:true,rangelength:[${site.passwordMinLen},20]}" class="register-input" /></li>
      <li><span>确认密码</span><input type="password" equalto="#password" vld="{required:true,rangelength:[${site.passwordMinLen},20]}" class="register-input" /></li>
      [#if validateType == 1||validateType == 0]       
      	<li><span>验证码</span><input type="text" maxlength="20" name="captcha" class="register-input register-code" /><i class="code-img"><img id="guestbookCaptcha"   alt="" src="${base}/captcha.svl"></i></li>
      [/#if]
      [#if validateType == 2]
       <li><span>验证码</span><input id="vCode" type="text" maxlength="20" name="vCode" class="register-input register-code" /><i class="code-img"><img id="guestbookCaptcha"   alt="" src="${base}/captcha.svl"></i></li>
       <li><span>校验码</span><input type="text" maxlength="20" name="captcha" class="register-input register-code" /><i class="code-img"><a id="getMobileCode">获取校验码</a></i></li>
      [/#if]
      <li class="register-txt"><input type="checkbox" class="register-checkbox" checked="checked" id="ck-agree"/>我已阅读并接受<a>《JEECMS注册协议》</a></li>
      <li class="register-btn">
      <input type="hidden" name="token"  value="${token!}" />
      <input type="submit" id="btn_sub" name="register"  value="立即注册" />
      </li>
    </ul>
  </div>
  </form>
</div>
[#include "../include/footer.html"/]
[#include "../include/right-fixed.html"/]
</body>
</html>
